package com.java.controller;

import java.util.Arrays;
import java.util.Map;

import com.java.pojo.OrderItems;
import com.java.service.OrderItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.java.common.utils.PageUtils;
import com.java.common.utils.R;



/**
 * 订单商品关联表 
 *
 * @author jl
 * @since 2020-10-13 11:31:41
 */
@RestController
@RequestMapping("/orderitems")
public class OrderItemsController {
    @Autowired
    private OrderItemsService orderItemsService;

    /**
     * 带条件分页查询订单商品关联表 
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderItemsService.queryPage(params);

	    return R.ok(page);
    }


    /**
     * 根据主键查询订单商品关联表 
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
		OrderItems orderItems = orderItemsService.getById(id);

        return R.ok(orderItems);
    }

    /**
     * 新增订单商品关联表 
     */
    @PostMapping("/save")
    public R save(@RequestBody OrderItems orderItems){
		orderItemsService.save(orderItems);

        return R.ok();
    }

    /**
     * 修改订单商品关联表 
     */
    @PutMapping("/update")
    public R update(@RequestBody OrderItems orderItems){
		orderItemsService.updateById(orderItems);

        return R.ok();
    }

    /**
     * 删除订单商品关联表 
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody String[] ids){
		orderItemsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
